package objectRank;

/**
 *
 * @author Reza Amini
 */
import java.io.Serializable;
import java.util.*;

public class Node implements Serializable{
    // Maps storing inLinks from different kinds of nodes
    HashMap<Integer, Double> inLinksFromGroups;
    HashMap<Integer, Double> inLinksFromUsers;
    HashMap<Integer, Double> inLinksFromQueries;
    HashMap<Integer, Double> inLinksFromDocuments;
    // Maps storing outLinks to different kids of nodes
    HashMap<Integer, Double> outLinksToGroups;
    HashMap<Integer, Double> outLinksToUsers;
    HashMap<Integer, Double> outLinksToQueries;
    HashMap<Integer, Double> outLinksToDocuments;
    Integer id;
    double rank;
}

// A User object has two attributes "userName" and "userId"
class User extends Node implements Serializable{
    private String userName;
    HashMap<Integer, Integer> clicksDocument;
    HashMap<Integer, Integer> submitsQuery;
    HashMap<Integer, Boolean> memberOfGroup;
    /**
    *
    * @param userName
    */
    public User(String userName){
        this.id = null;
        this.userName = userName;
        this.inLinksFromGroups = new HashMap<Integer, Double>();
        this.inLinksFromQueries = new HashMap<Integer, Double>();
        this.inLinksFromDocuments = new HashMap<Integer, Double>();
        this.outLinksToGroups = new HashMap<Integer, Double>();
        this.outLinksToQueries = new HashMap<Integer, Double>();
        this.outLinksToDocuments = new HashMap<Integer, Double>();
        this.clicksDocument = new HashMap<Integer, Integer>();
        this.submitsQuery = new HashMap<Integer, Integer>();
        this.memberOfGroup = new HashMap<Integer, Boolean>();
        this.rank = 1.0;
    }
    
    /**
    *
    * @return The user name
    */
    public String getUserName(){
        return userName;
    }

    public void setUserName(String userName){
        this.userName = userName;
    }

    public String toString(){
        return userName;
    }
}

// A Group object has two attributes "groupName" and "groupDescription"
class Group extends Node implements Serializable{
    private String groupDescription;
    HashMap<Integer, Boolean> containsUser;
    /**
    *
    * @param groupDescription
    */
    public Group(String groupDescription){
        this.id = null;
        this.groupDescription = groupDescription;
        this.inLinksFromUsers = new HashMap<Integer, Double>();
        this.inLinksFromGroups = new HashMap<Integer, Double>();
        this.inLinksFromQueries = new HashMap<Integer, Double>();
        this.outLinksToUsers = new HashMap<Integer, Double>();
        this.outLinksToGroups = new HashMap<Integer, Double>();
        this.outLinksToQueries = new HashMap<Integer, Double>();
        this.containsUser = new HashMap<Integer, Boolean>();
        this.rank = 1.0;
    }
    /**
    *
    * @return The group description
    */
    public String getGroupDescription(){
        return groupDescription;
    }

    public void setGroupDescription(String groupDescription){
        this.groupDescription = groupDescription;
    }

    public String toString(){
        return groupDescription;
    }
}

// A Query object has the attribute "query" which keeps the submitted query by user
class Query extends Node implements Serializable{
    private String query;
    HashMap<Integer, Integer> displayDocument;
    HashMap<Integer, Integer> submittedByUser;
    ArrayList<Node> rootSet;
    /**
    *
    * @param query
    */
    public Query(String query){
        this.id = null;
        this.query = query;
        this.inLinksFromUsers = new HashMap<Integer, Double>();
        this.inLinksFromGroups = new HashMap<Integer, Double>();
        this.inLinksFromQueries = new HashMap<Integer, Double>();
        this.inLinksFromDocuments = new HashMap<Integer, Double>();
        this.outLinksToUsers = new HashMap<Integer, Double>();
        this.outLinksToGroups = new HashMap<Integer, Double>();
        this.outLinksToQueries = new HashMap<Integer, Double>();
        this.outLinksToDocuments = new HashMap<Integer, Double>();
        this.displayDocument = new HashMap<Integer, Integer>();
        this.submittedByUser = new HashMap<Integer, Integer>();
        this.rank = 1.0;
        rootSet = new ArrayList<Node>();
    }
    /**
    *
    * @return The submitted query
    */
    public String getQuery(){
        return query;
    }

    public void setQuery(String query){
        this.query = query;
    }

    public String toString(){
        return query;
    }
}

// A Document object has the attribute "link" which keeps the link to the document on the web
class Document extends Node implements Serializable{
    private String URL;
    private String title;
    private String content;
    HashMap<Integer, Integer> clickedByUser;
    HashMap<Integer, Integer> displayedAfterQuery;
    HashMap<Integer, Integer> clickedAfterQuery;
    /**
    *
    * @param URL
    */
    public Document(String URL){
        this.id = null;
        this.URL = URL;
        this.title = null;
        this.content = null;
        this.inLinksFromUsers = new HashMap<Integer, Double>();
        this.inLinksFromQueries = new HashMap<Integer, Double>();
        this.outLinksToUsers = new HashMap<Integer, Double>();
        this.outLinksToQueries = new HashMap<Integer, Double>();
        this.clickedByUser = new HashMap<Integer, Integer>();
        this.displayedAfterQuery = new HashMap<Integer, Integer>();
        this.clickedAfterQuery = new HashMap<Integer, Integer>();
        this.rank = 1.0;
    }
    /**
    *
    * @return The link to the document on the web
    */
    public String getURL(){
        return URL;
    }

    public void setURL(String URL){
        this.URL = URL;
    }

    public String getTitle(){
        return title;
    }

    public void setTitle(String title){
        this.title = title;
    }

    public String getContent(){
        return content;
    }

    public void setContent(String content){
        this.content = content;
    }

    public String toString(){
        return URL;
    }
}

